package com.kvest.gpsservicetracker.datamodel;

import android.location.Location;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DBLocationItem {
    private long time;
    private double latitude;
    private double longitude;
    private float altitude;
    private float speed;
    private float accuracy;
    private float bearing;

    public DBLocationItem(long time) {
        this.time = time;
        latitude = 0.0f;
        longitude = 0.0f;
        altitude = 0.0f;
        speed = 0.0f;
        accuracy = 0.0f;
        bearing = 0.0f;
    }

    public DBLocationItem(Location location) {
        time = location.getTime();
        latitude = location.getLatitude();
        longitude = location.getLongitude();
        altitude = (float)location.getAltitude();
        speed = location.getSpeed();
        accuracy = location.getAccuracy();
        bearing = location.getBearing();
    }

    public DBLocationItem() {
        this(-1L);
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public float getAltitude() {
        return altitude;
    }

    public void setAltitude(float altitude) {
        this.altitude = altitude;
    }

    public float getSpeed() {
        return speed;
    }

    public void setSpeed(float speed) {
        this.speed = speed;
    }

    public float getAccuracy() {
        return accuracy;
    }

    public void setAccuracy(float accuracy) {
        this.accuracy = accuracy;
    }

    public float getBearing() {
        return bearing;
    }

    public void setBearing(float bearing) {
        this.bearing = bearing;
    }

    @Override
    public String toString() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return "[time=" + sdf.format(new Date(time)) + ", latitude=" + latitude  + ", longitude=" + longitude +
                ", altitude=" + altitude + ", speed=" + speed + ", accuracy=" + accuracy +
                ", bearing=" + bearing + "]";
    }
}
